﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetPostiler]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetPostiler];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetPostiler]
    @DocID int
AS
SELECT A.*,datediff(yy,a.birthday,getdate()) as Age,(case sex when 1 then '男' else '女' end) as SexName,Convert(nvarchar(10),A.RegistedDate,120) AS RQ,(SELECT Position_name FROM uds_Position WHERE Position_id = b.Position_id) AS Position_Name
    FROM uds_staff A,uds_staff_in_position b
    WHERE a.staff_id = b.staff_id
    and   a.staff_id IN
            (    
                SELECT staff_id 
                    FROM uds_flow_status
                    WHERE doc_id = @DocID
                      And status=2
            )